﻿using Three_Week.Model;

namespace Three_Week.DAL
{
    public class HouseDal
    {
        private readonly Mycontext context;

        public HouseDal(Mycontext _context)
        {
            context = _context;
        }
        /// <summary>
        /// 房型添加
        /// </summary>
        /// <param name="V"></param>
        /// <returns></returns>
        public int HouseAdd(HouseType V)
        {
            try
            {
                var Great = context.House.Count(D => D.HouseTypeName == V.HouseTypeName);
                if (Great > 0)
                {
                    return -1;
                }
                else
                {
                    context.Add(V);
                    return context.SaveChanges();
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
